/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package sistemperpustakaan.actionlistener;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyVetoException;
import javax.swing.JInternalFrame;
import sistemperpustakaan.controller.DendaController;
import sistemperpustakaan.view.FrmMain;
import sistemperpustakaan.view.denda.FrmDendaBuku;
import sistemperpustakaan.view.user.FrmTipeUserView;

/**
 *
 * @author EKo
 */
public class ViewSettingDendaActionListener implements ActionListener{
FrmMain main;
DendaController controller;
    public ViewSettingDendaActionListener(FrmMain main) {
        this.main = main;
    }
public boolean isExists(){
        boolean result = false;
        JInternalFrame[] iFrame = main.getDesktopPane().getAllFrames();
        for(int i=0;i < iFrame.length; i++){
            if(iFrame[i].equals(main.getDendaBuku())){
                result = true; break;
            }
        }
        return result;
    }
    public void actionPerformed(ActionEvent e) {
         if(isExists()){
            try {
                main.getDendaBuku().setSelected(true);
            } catch (PropertyVetoException ex) {
            }
         }else{
            main.setDendaBuku(new FrmDendaBuku(main));
            main.getDesktopPane().add(main.getDendaBuku());
            //try { main.getTipeUserView().setMaximum(true); } catch (PropertyVetoException ex) {  }
            main.getDendaBuku().setVisible(true);
         }
    }

}
